import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Tag} from '../../../../entity/tag.model';

@Component({
  selector: 'app-matrix-tag-selector',
  templateUrl: './matrix-tag-selector.component.html',
  styleUrls: ['./matrix-tag-selector.component.css']
})
export class MatrixTagSelectorComponent implements OnInit {
  /**
   *
   *
   * @type {Tag[]}
   * @memberof MatrixTagSelectorComponent
   */
  @Input() matrixTags: Tag[];

  /**
   *
   *
   * @type {Tag}
   * @memberof MatrixTagSelectorComponent
   */
  @Input() selectedTag: Tag;

  /**
   * 选中项发生改变
   *
   *
   * @memberof FarmSelectorComponent
   */
  @Output() selectedChange: EventEmitter<Tag> = new EventEmitter<Tag>();

  constructor() {

  }

  ngOnInit() {

  }

  /**
   *
   *
   * @param {Tag} tag
   * @memberof MatrixTagSelectorComponent
   */
  onClick(tag: Tag) {
    if (this.selectedTag !== tag) {
      this.selectedTag = tag;
      this.selectedChange.emit(this.selectedTag);
    }
  }
}
